Skip to content

docs: update macos openmp instructions#530

Merged
adrn merged 2 commits intomainfrom
exp-readme-openmp
Apr 20, 2026
Merged

docs: update macos openmp instructions#530
adrn merged 2 commits intomainfrom
exp-readme-openmp

Conversation

@lgarrison
Copy link
Copy Markdown
Collaborator

Not sure if we also need to instruct people to set CC and CXX to the LLVM compiler, or if it will be the default. @adrn maybe you could test this?

@adrn
Copy link
Copy Markdown
Owner

adrn commented Mar 5, 2026

I think I was able to get it to work with the clang + openmp by replacing (in setup.py):

            ext.extra_compile_args.extend(["-fopenmp"])
            ext.extra_link_args.extend(["-fopenmp"])

with

            # OpenMP support: macOS with Apple clang requires different flags
            if sys.platform == "darwin":
                # Check if using Apple clang (doesn't support -fopenmp directly)
                # Use -Xpreprocessor -fopenmp with libomp from Homebrew
                libomp_prefix = os.environ.get(
                    "LIBOMP_PREFIX", "/opt/homebrew/opt/libomp"
                )
                ext.include_dirs.append(os.path.join(libomp_prefix, "include"))
                ext.library_dirs.append(os.path.join(libomp_prefix, "lib"))
                ext.extra_compile_args.extend(["-Xpreprocessor", "-fopenmp"])
                ext.extra_link_args.extend(["-lomp"])
            else:
                ext.extra_compile_args.extend(["-fopenmp"])
                ext.extra_link_args.extend(["-fopenmp"])

@lgarrison
Copy link
Copy Markdown
Collaborator Author

Just so I understand: is this for the case that the user has done brew install libomp but not brew install libomp llvm? So they have /opt/homebrew/opt/libomp but are using Apple Clang?

Basically, my understanding/guess is that to use LLVM Clang, one is supposed to use brew install llvm libomp (less sure about libomp) and clang -fopenmp, and with Apple Clang, use brew install libomp and -lomp -Xpreprocessor -fopenmp. Is that your understanding?

@adrn
Copy link
Copy Markdown
Owner

adrn commented Mar 5, 2026

Yes I think that's right! Or at least, that's my current understanding :)

@lgarrison
Copy link
Copy Markdown
Collaborator Author

The if sys.platform == "darwin": check will use the -Xpreprocessor form even if the user has installed LLVM Clang, though, right? Do we know if that works/has any negative side effects?

@adrn
Copy link
Copy Markdown
Owner

adrn commented Apr 20, 2026

Failure I think is because of a gaia archive downtime?

@adrn adrn merged commit 2ae42b6 into main Apr 20, 2026
28 of 29 checks passed
@adrn adrn deleted the exp-readme-openmp branch April 20, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants